<template>
  <div class="msg-page">
    <div class="page-title">消息通知</div>
    <template v-if="msgList?.length">
      <div class="msg-list" v-for="item in msgList" :key="item">
        <div class="msg-item">
          <el-card shadow="always"  @click="goDetailPage(item.businessId, '1')" >
            <div class="card">
              <div class="content">
                <el-tag style="margin-right:5px" type="success">已读</el-tag>
                <p>{{ item.content }}</p>
                <span style="margin-left:5px;color: #409eff;text-decoration: underline;cursor: pointer;">点击查看</span>
              </div>
              <p style="text-align: right;">{{item.createTime}}</p>
            </div>
          </el-card>
        </div>
      </div>
    </template>
    <el-empty v-else description="空空如也~" />
  </div>
</template>

<script setup lang="ts">
import { useMsgHooks } from "./hooks";

const { msgList } = useMsgHooks();
  const goDetailPage = (id: string, searchType: any) => {
    if(!id){ ElNotification({
          title: "错误",
          message: "网络错误!",
          type: "error"
        }); return }
    window.open(`${location.origin}/detail?id=${id}&searchType=${searchType}`, "_blank")
  }
</script>

<style scoped lang="postcss">
.msg-page {
  @apply bg-white py-2 px-4;
  .page-title {
    @apply font-bold mb-4 text-xl;
  }
  .msg-item {
    @apply mb-3;
    .card{
      @apply flex items-center;
    justify-content: space-between;
      .content {

      @apply flex items-center;
      white-space: nowrap !important;
      text-overflow: ellipsis !important;
      overflow: hidden !important;
      width:80%;
    }
    }
  }
}
</style>
